﻿using AllServer.Account.Application.Services;
using AllServer.Share;
using Furion.DependencyInjection;
using MagicOnion;
using MagicOnion.Server;

namespace AllService.GrpcService.Account.Service;

public class MemberGrpcService : ServiceBase<IMemberGrpcService>, IMemberGrpcService, ITransient
{
    private readonly IMemberService _memberService;

    public MemberGrpcService(IMemberService memberService)
    {
        _memberService = memberService;
    }


    public async UnaryResult<MemberInfo> GetMember(string userCode)
    {
        var member = await _memberService.GetMember(userCode);
        if (member != null)
        {
            return new MemberInfo()
            {
                MemberId = member.Id,
                MemberName = member.UserCode
            };
        }
        return null;
    }

    public async UnaryResult<bool> IsMember(int memberId)
    {
        return true;
    }
}
